package com.fdb.efp.nls.service.impl.sx.zxruleforbd;

import com.fdb.cdp.pboc.service.vo.BdZxInfoVO;
import com.fdb.efp.rule.service.vo.ReqBdCreditRuleVo;
import org.springframework.stereotype.Service;

import java.util.function.IntPredicate;
import java.util.stream.Stream;

/**
 * 贷记卡最近12个月连续3次或者以上逾期（任意一笔贷款） <br>
 * <p>
 * 0.1:caoxin:2019/7/10 17:03: <br>
 * @author caoxin
 * @version 0.1
 * @date 2019/7/10 17:03
 * @since 2019/7/10 17:03
 */
@Service("bDZxRule05")
public class BDZxRule05 implements BdZxRuleInterface{
    private static final IntPredicate ifOverdueStatus = c -> (c >= '3' && c <= '7');
    @Override
    public void executeRule(ReqBdCreditRuleVo reqBdCreditRuleVo,BdZxInfoVO bdZxInfoVO) {
        int sum =  Stream.of(bdZxInfoVO.getZxCreditCardDelqStatus30Dayyues(),
                bdZxInfoVO.getZxCreditCardDelqStatus30to60days(),
                bdZxInfoVO.getZxCreditCardDelqStatus60to90days(),
                bdZxInfoVO.getZxCreditCardDelqStatus90to180days(),
                bdZxInfoVO.getZxCreditCardDelqStatus6to12months()).mapToInt(i -> i.chars().filter(ifOverdueStatus).map(e -> 1).sum()).sum();
        reqBdCreditRuleVo.setRule05(sum);
    }
}
